package org.bw.bookstore.book.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.bw.bookstore.book.service.impl.InventoryTaskServiceImpl;
import org.bw.bookstore.common.entity.TbInventoryTask;
import org.bw.bookstore.common.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 *@program:wisdom_bookstore
 *@description:盘点任务控制层
 *@author:孙冬雪
 *@create:2020-10-22 09:50
 */
@CrossOrigin
@RestController
@Slf4j
@Api(tags = "接口-盘点任务管理")
public class InventoryTaskController {

    @Autowired
    private InventoryTaskServiceImpl inventoryTaskService;

    /**
     * @Description 根据对应盘点规则定时生成盘点任务
     * TODO 孙冬雪--> markInventoryTask 生成盘点任务
     * @Param [inventoryRules]
     * @Return com.bw.common.utils.ResponseResult
     * @Author 孙冬雪
     * @Date 2020/10/22 11:00
     **/
    @PostMapping("/markInventoryTask")
    @ApiOperation(value="生成盘点任务", notes="生成盘点任务")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "inventoryTime", value = "盘点时间",dataType = "Date",required = true),
            @ApiImplicitParam(name = "bookDetailedCode", value = "图书详情标识",dataType = "String",required = true)
    })
    public ResponseResult markInventoryTask(@ApiIgnore TbInventoryTask tbInventoryTask) {
        return inventoryTaskService.markInventoryTask(tbInventoryTask);
    }

    /**
     * TODO 查询全部未完成的盘点任务
     * @Description:
     * @Author: liuwu
     * @Date: 2020/10/26 18:54
     * @return: com.bw.servercommon.utils.ResponseResult
     **/
    @ApiOperation(value="查询全部未完成的盘点任务", notes="查询全部未完成的盘点任务")
    @PostMapping("/getInventoryTaskByNoFinish")
    public ResponseResult getInventoryTaskByNoFinish(){
        return inventoryTaskService.getInventoryTaskByNoFinish();
    }

    /**
     * TODO 查询全部已完成的盘点任务
     * @Description:
     * @Author: liuwu
     * @Date: 2020/10/26 18:54
     * @return: com.bw.servercommon.utils.ResponseResult
     **/
    @ApiOperation(value="查询全部已完成的盘点任务", notes="查询全部已完成的盘点任务")
    @PostMapping("/getInventoryTaskByFinish")
    public ResponseResult getInventoryTaskByFinish(){
        return inventoryTaskService.getInventoryTaskByFinish();
    }

    /**
     * TODO 查询全部盘点任务
     * @Description:
     * @Author: liuwu
     * @Date: 2020/10/26 18:54
     * @return: com.bw.servercommon.utils.ResponseResult
     **/
    @ApiOperation(value="查询全部盘点任务", notes="查询全部盘点任务")
    @PostMapping("/getInventoryTask")
    public ResponseResult getInventoryTask(){
        return inventoryTaskService.getInventoryTask();
    }



    @ApiOperation(value = "工作人员登录", notes = "工作人员登录")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "userName", value = "工作人员账号", dataType = "String", required = true),
            @ApiImplicitParam(name = "userPass", value = "工作人员密码", dataType = "String", required = true)
    })
    @PostMapping("/loginStaffMember")
    public ResponseResult loginStaffMember(String userName,String userPass){
        return inventoryTaskService.loginStaffMember(userName,userPass);
    }

    @ApiOperation(value="查询全部图示品类", notes="查询全部图示品类")
    @PostMapping("/getBookDetailed")
    public ResponseResult getBookDetailed(){
        return inventoryTaskService.getBookDetailed();
    }
}
